package com.atguigu.aoppreview.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * @Author: shenhao
 * @CreatTime: 2024/11/3 15:08
 * @Version: 1.0
 */
@Component
@Aspect
public class PayAspect {
    @Pointcut("execution(public void com.atguigu.aoppreview.PayServiceImpl.pay(..))")
    public void myPointCut(){}
    @Before("myPointCut()")
    public void beforeNotify(){
        System.out.println("----@Before前置通知");
    }

    @After("myPointCut()")
    public void afterNotify(){
        System.out.println("----@After后置通知");
    }
    @AfterReturning("myPointCut()")
    public void afterReturn(){
        System.out.println("-----@AfterReturning返回通知");
    }

    @AfterThrowing("myPointCut()")
    public void afterThrowing(){
        System.out.println("-------@AfterThrowing异常通知--");
    }

    @Around("myPointCut()")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
        Object retVal = null;
        System.out.println("---------@Around环绕通知AAA");
        retVal = joinPoint.proceed();
        System.out.println("---------@Around环绕通知BBB");
        return retVal;
    }

}
